<?php
/**
 * @author Amissah Gideon<kuulmek@yahoo.com>
 * @access public
 * @version 1.0
 */
?>
<!-- Main content -->
<section role="main" id="main">

    <!-- Header -->
    <?php
        echo $this->element('page_header');
        echo $this->element('navigations/proforma_navbar');
    ?>

    <div class="with-padding">
        <div class="columns">
            <div class="new-row-mobile twelve-columns six-columns-tablet twelve-columns-mobile">

                <h3 class="thin underline">Generate Invoice</h3>
                <div class="boxed with-border" style="margin-bottom: 20px;">
                    <div style="float: left; margin-right: 60px;">
                        <?php echo $this->Form->input('all_customers', array('id'=>'all_customers', 'class' => 'select expandable-list validate[required] ', 'style'=>'width:170px;','options'=>$all_customers, 'default'=>0,'div' => false, 'label' => false)); ?>
                        &nbsp;
                        Or
                        &nbsp;
                        <button type="button" class="button" id="add-new-customer">
                            <span class="button-icon blue-gradient"><span class="icon-plus"></span></span>
                            Add New Customer
                        </button>
                    </div>

                    <div>
                        <?php echo $this->Form->input('all_items', array('id'=>'all_items', 'class' => 'select expandable-list validate[required] ', 'style'=>'width:170px;','options'=>$all_items, 'default'=>0,'div' => false, 'label' => false)); ?>
                    </div>
                </div>

                <?php echo $this->Form->create('Proforma', array('default' => false, 'id' => 'proforma-form','inputDefaults' => array('label' => false,'div' => false)));?>

                <fieldset class="fieldset">
                    <legend id="legend-text" class="legend" style="font-size: 14px; font-weight: bolder">Invoice</legend>

                    <p class="button-height inline-label">
                        <span class="label">Officer In Charge</span>
                        <?php echo $this->Form->input('officer_incharge', array('id'=>'officer_incharge', 'class' => 'input validate[required] ','default'=>$authUser['first_name'].' '.$authUser['middle_name'].' '.$authUser['last_name'],'div' => false, 'label' => false)); ?>
                    </p>
                    <p class="button-height inline-label">
                        <span class="label">Phone Number</span>
                        <?php echo $this->Form->input('fon_number', array('id'=>'fon_number', 'class' => 'input validate[required] ','div' => false, 'label' => false)); ?>
                    </p>

                    <p class="button-height inline-label">
                        <span class="label">Sales Type</span>

							<span class="button-group">
								<label for="sales-type-radio-1" class="button green-active">
                                    <input type="radio" name="sales-type-radio" id="sales-type-radio-1" value="out_right_purchase" checked>
                                    Out-Right Purchase
                                </label>
								<label for="sales-type-radio-2" class="button green-active">
                                    <input type="radio" name="sales-type-radio" id="sales-type-radio-2" value="credit">
                                    Credit Purchase
                                </label>
							</span>
                    </p>

                    <div class="invoice_table" ></div>
                    <table id="invoice_table" class="table table-bordered">
                        <thead>
                            <tr>
                                <th>Item</th>
                                <th>Qty</th>
                                <th>Discount %</th>
                                <th>Modify</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>

                    <p class="button-height inline-label">
                        <label for="generate-invoice-btn" class="label">&nbsp;</label>
                        <button type="submit" class="button" id="generate-invoice-btn">
                            <span class="button-icon green-gradient"><span class="icon-page-list"></span></span>
                            Generate Proforma
                        </button>

                        <button type="button" class="button" id="clear-invoice-btn">
                            <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                            Clear
                        </button>
                    </p>

                </fieldset>

                <?php echo $this->Form->end();?>


                <div style="display: none;">
                    <div  id="customer-form-window"  style="margin: 20px 5px 5px 5px;">
                        <div class="prompt" ></div>
                        <?php echo $this->Form->create('Customer', array('default' => false, 'id' => 'customer-form', 'action' => 'addNewCustomer','inputDefaults' => array('label' => false,'div' => false)));?>
                        <fieldset class="fieldset">
                            <legend class="legend">Info</legend>

                            <p class="button-height inline-label">
                                <label class="label">Name:</label>
                                <?php echo $this->Form->input('name', array('id'=>'name', 'class' => 'input validate[required] ', 'div' => false, 'label' => false,)); ?>
                            </p>
                            <p class="button-height inline-label">
                                <label class="label">Customer Type:</label>
                                <?php echo $this->Form->input('customer_type', array('id'=>'customer_type', 'class' => 'select validate[required] ', 'options'=>$customer_types_opt, 'div' => false, 'label' => false,)); ?>
                            </p>
                            <p class="button-height inline-label">
                                <label class="label">Certificate of Incorporation:</label>
                                <?php echo $this->Form->input('certificate_no', array('id'=>'certificate_no', 'class' => 'input' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Date of Commencement:</label>
                                <span class="input">
                                    <?php echo $this->Form->input('date_of_commence', array('type'=>'text','id'=>'date_of_commence', 'class' => 'input-unstyled','div' => false, 'label' => false,)); ?>
                                    <!--<input type="text" name="pseudo-input-1" id="pseudo-input-1" class="input-unstyled" value="Value">-->
                                    <a href="javascript:void(0)" class="button compact" id="date_of_commence_btn">Date</a>
                                </span>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Contact Person:</label>
                                <?php echo $this->Form->input('contact_person', array('id'=>'contact_person', 'class' => 'input validate[required]' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Telephone:</label>
                                <?php echo $this->Form->input('phone_number', array('id'=>'phone_number', 'class' => 'input validate[required]' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Email:</label>
                                <?php echo $this->Form->input('email', array('id'=>'email', 'class' => 'input' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Address:</label>
                                <?php echo $this->Form->input('address', array('id'=>'address', 'class' => 'input' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Region:</label>
                                <?php echo $this->Form->input('region_id', array('id'=>'region_id', 'class' => 'select expandable-list', 'style'=>'width:170px;','options'=>$region_list ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">City:</label>
                                <?php echo $this->Form->input('city', array('id'=>'city', 'class' => 'input' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Location:</label>
                                <?php echo $this->Form->input('physical_location', array('type'=>'text','id'=>'physical_location', 'class' => 'input validate[required]' ,'value'=>'', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Country:</label>
                                <?php echo $this->Form->input('country_id', array('id'=>'country_id', 'class' => 'select expandable-list validate[required]', 'style'=>'width:170px;','options'=>$country_list, 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Comments:</label>
                                <?php echo $this->Form->input('comments', array('id'=>'comments', 'class' => 'input full-width validate[required]', 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label for="save-customer-btn" class="label">&nbsp;</label>
                                <button type="submit" class="button" id="save-customer-btn">
                                    <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                                    Save
                                </button>

                                <button type="button" class="button" id="cancel-customer-btn">
                                    <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                                    Cancel
                                </button>
                            </p>
                        </fieldset>

                        <?php echo $this->Form->end();?>
                    </div>
                </div>


                <!-- Adding Proforma items -->
                <div style="display: none;">
                    <div  id="item-form-window"  style="margin: 20px 5px 5px 5px;">
                        <div class="prompt" ></div>
                        <?php echo $this->Form->create('Item', array('default' => false, 'id' => 'item-form', 'action' => '','inputDefaults' => array('label' => false,'div' => false)));?>
                        <fieldset class="fieldset">
                            <legend class="legend">Info</legend>

                            <p class="button-height inline-label">
                                <label class="label" id="item-label-name" style="width: auto"></label>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Quantity:</label>
                                <?php echo $this->Form->input('quantity', array('id'=>'quantity', 'class' => 'input validate[required] ', 'value'=>1,'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label">Discount %:</label>
                                <?php echo $this->Form->input('discount', array('id'=>'discount', 'class' => 'input validate[required]' ,'value'=>0, 'div' => false, 'label' => false,)); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label class="label"></label>
                                <?php echo $this->Form->input('item_id', array('type'=>'hidden','id'=>'item_id')); ?>
                                <?php echo $this->Form->input('item_name', array('type'=>'hidden','id'=>'item_name')); ?>
                            </p>

                            <p class="button-height inline-label">
                                <label for="save-customer-btn" class="label">&nbsp;</label>
                                <button type="submit" class="button" id="save-item-btn">
                                    <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                                    Save
                                </button>

                                <button type="button" class="button" id="cancel-item-btn">
                                    <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                                    Cancel
                                </button>
                            </p>
                        </fieldset>

                        <?php echo $this->Form->end();?>
                    </div>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- End main content -->

<!-- Side tabs shortcuts -->
<?php echo $this->element('side_tabs_shortcuts'); ?>
<!-- Sidebar/drop-down menu -->
<?php echo $this->element('right_side_infos'); ?>


<!-- Users URL -->
<input type="hidden" id="table-url" value="<?php echo $this->Html->url(array('controller' => 'Proforma', 'action' => 'get')); ?>" />
<input type="hidden" id="add-edit-url" value="<?php echo $this->Html->url(array('controller' => 'Proforma', 'action' => 'add')); ?>" />
<input type="hidden" id="load-user-url" value="<?php echo $this->Html->url(array('controller' => 'Proforma', 'action' => 'load')); ?>" />
<input type="hidden" id="delete-url" value="<?php echo $this->Html->url(array('controller' => 'Proforma', 'action' => 'delete_')); ?>" />
<input type="hidden" id="print-invoice-url" value="<?php echo $this->Html->url(array('controller' => 'Proforma', 'action' => 'print_proforma_invoice')); ?>" />


<?php
echo $this->Html->script('setup.js');

/** Template functions **/
echo $this->Html->script('developr.input.js');
echo $this->Html->script('developr.message.js');
echo $this->Html->script('developr.modal.js');
echo $this->Html->script('developr.navigable.js');
echo $this->Html->script('developr.notify.js');
echo $this->Html->script('developr.scroll.js');
echo $this->Html->script('developr.progress-slider.js');
echo $this->Html->script('developr.tooltip.js');
echo $this->Html->script('developr.confirm.js');
echo $this->Html->script('developr.agenda.js');
echo $this->Html->script('developr.tabs.js');

echo $this->Html->script('libs/tinycon.min.js');
echo $this->Html->script('jquery.thfloat-0.3.min.js');
echo $this->Html->script('custom-scripts/new_proforma.js');
?>